package com.ai.web.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.ai.web.service.BgMenuService;
import com.ai.web.vo.BgMenuV;
import com.ai.web.vo.ResultModel;
import com.tiny.persistence.domain.BgMenu;
import com.tiny.persistence.repository.BgMenuRepo;

@Service
public class BgMenuServiceImpl extends BaseServiceImpl<BgMenu, Integer, BgMenuV> implements BgMenuService  {

    @Autowired
    private BgMenuRepo bgMenuRepo;
    
    @Autowired
    public BgMenuServiceImpl(BgMenuRepo bgMenuRepo) {
        super(bgMenuRepo);
    }

    public BgMenuV getBgMenu(int userId) throws Exception {
        return getT(userId);
    }

    public ResultModel saveBgMenu(BgMenuV bgMenuV) throws Exception {
        
        BgMenuV saveV = saveT(bgMenuV);
        
        ResultModel rm = new ResultModel();
        rm.setData(saveV);
        rm.setSuccessCode();
        
        return rm;
    }

    public ResultModel deleteBgMenus(List<Integer> userIds) throws Exception {
        deleteTs(userIds);
        
        ResultModel rm = new ResultModel();
        rm.setSuccessCode();
        rm.setMsg("删除成功！");
        
        return rm;
    }

    public List<BgMenu> findFirstLevelMenuList(int groupId) {
        return bgMenuRepo.findFirstLevelMenuList(groupId);
    }

    public List<BgMenu> findSecondLevelMenuListByMenuId(int menuId, int bgroleId) {
        return bgMenuRepo.findSecondLevelMenuListByMenuId(menuId, bgroleId);
    }

	public List<BgMenu> findAllMenuList(int bgroleId) {
		 return bgMenuRepo.findAllMenuList(bgroleId);
	}


}
